//
//  JYTaBarController.swift
//  JYCalculate
//
//  Created by 何治军 on 2018/10/26.
//  Copyright © 2018 何治军. All rights reserved.
//

import UIKit

class JYTaBarController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        addChilds()
    }
    
    func addChilds() {
        let firstVC = JYHomeViewController()
        firstVC.title = Localized("tabar-home")
        self .addChild(UINavigationController(rootViewController: firstVC))
        
        let secondVC = JYMineViewController()
        secondVC.title = Localized("tabar-mine")
        self .addChild(UINavigationController(rootViewController: secondVC))
        self.tabBar.tintColor = JYNavigationBarColor
    }
    
    func changeTarbarItem(){
        if let count = self.tabBar.items?.count {
            for index in 0 ..< count {
                let item = self.tabBar.items![index]
                var imgName:String!
//                var imgNameS:String!
                if index == 0 {
                    imgName = "tabbar_home"
//                    imgNameS = "tabbar_calculate_s"
                    
                }else if index == 1 {
                    imgName = "tabbar_mine";
//                    imgNameS = "tabbar_mine_s";
                }
                item.image = UIImage(named: imgName)?.withRenderingMode(.alwaysTemplate)
//                item.selectedImage = UIImage(named: imgNameS)?.withRenderingMode(.alwaysTemplate)
            }
        }

    }
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        changeTarbarItem()
    }
}
